package com.testapp.bluetoothtest08.File;


import com.testapp.bluetoothtest08.Constant.Constants;

import java.io.File;

public class Params {
    File day = new File("/data/data/com.testapp.bluetoothtest08/day.txt");
    File time = new File("/data/data/com.testapp.bluetoothtest08/time.txt");
    File LastT = new File("/data/data/com.testapp.bluetoothtest08/LastT.txt");
    File key = new File("/data/data/com.testapp.bluetoothtest08/Key.txt");

    BaseFileOperation bfo = new BaseFileOperation();

    public Params() {
        init();
    }

    public void init() {
        if (!bfo.isExist(day)) {
            bfo.write(day, "");
        }
        if (!bfo.isExist(time)) {
            bfo.write(time, "");
        }
        if (!bfo.isExist(LastT)) {
            bfo.write(LastT, "");
        }
        if (!bfo.isExist(key)) {
            bfo.write(key, "");
        }
    }

    //写入day
    public void writeDay(int i) {
        bfo.write(day, Integer.toString(i));
    }

    //写入time
    public void writeTime(int j) {
        bfo.write(time, Integer.toString(j));
    }

    //写入lastT
    public void writeLastT(String string) {
        bfo.write(LastT, string);
    }

    //写入key
    public void writeKey(String string) {
        bfo.write(key, string);
    }


    //读取day
    public int readDay() {
        return bfo.readInt(day);
    }

    //读取time
    public int readTime() {
        return bfo.readInt(time);
    }

    //读取LastT
    public String readLastT() {
        return bfo.readString(LastT);
    }

    //读取key
    public String readKey() {
        return bfo.readString(key);
    }


    //清除day
    public void clearDay() {
        bfo.write(day, "");
    }

    //清除time
    public void clearTime() {
        bfo.write(time, "");
    }

    //清除LastT
    public void clearLastT() {
        bfo.write(LastT, "");
    }

    //清除Key
    public void clearKey() {
        bfo.write(day, "");
    }

    //更换key
    public void changeKey() {
        Constants.key = String.valueOf((int) (Math.random() * 100));
        writeKey(Constants.key);
    }


}
